SOConnect


C Specification

#include <dolphin/socket.h>
int SOConnect ( int s, const void* sockAddr );

Description

SOConnect() attempts to make a connection on a socket. If the socket has not already been bound to a local address, SOConnect() binds it to an address which is unused and local.

For SO_SOCK_STREAM (TCP) sockets, SOConnect() normally blocks until the connection is established. SOConnect() returns as quickly as possible if the socket is set to the nonblocking mode with SOFcntl().

For SOCK_DGRAM (UDP) sockets, SOConnect() sets the socket's peer address, and no connection is made. The peer address identifies where all datagrams are sent on subsequent SOSend() functions, and limits the remote sender for subsequent SORecv() functions. If sockAddr is a null address for the protocol, the socket's peer address is reset.

Arguments

s The socket descriptor.
sockAddr A pointer to a socket address structure containing the peer address.

Return Values

zero Succeeded.
SO_EAFNOSUPPORT Non-supported address family.
SO_EBADF Bad socket descriptor.
SP_ECONNREFUSED Connection refused.
SP_ECONNRESET Connection reset.
SO_EINPROGRESS O_NONBLOCK is set for the socket descriptor and the connection cannot be immediately established; the connection will be established asynchronously.
SO_EINVAL Invalid operation.
SO_EISCONN Socket is already connected.
SO_ENETDOWN Local network interface is down.
SO_ENETRESET Socket library is not initialized.
S0_ENETUNREACH Unreachable.
SO_ENOBUFS Insufficient resources.
SO_ETIMEDOUT Timed out.

Note: Additional errors may be generated and returned in future library releases. All the negative return values must be treated as generic errors.

See Also

SOFcntl(), SOGetPeerName()